import BaseView from "../baseView.js";
export default class AddSeats extends BaseView {
    render() {
        $('#Content').html(`
        <div style="margin: 30px 10px 0 20px " id='nav'>
        <span class="layui-breadcrumb">
            <a>选座管理系统/</a>
            <a>选座资料管理/</a>
            <a>新增选座数据列表</a>
         </span>
         <hr/>
        </div>
        <h1 style="margin: 10px 10px 0 20px ">新增选座</h1>
        <hr/>
        <div style='width:300px;margin:auto'>
        <form class="layui-form" action="" lay-filter="formTest" >
        <div class="layui-form-item">
            <label class="layui-form-label">行</label>
            <div class="layui-input-block">
                <input type="text" name="title" required lay-verify="required" placeholder="请输入行" autocomplete="off"
                    class="layui-input" id="student_name">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">列</label>
            <div class="layui-input-block">
                <input type="text" name="title" required lay-verify="required" placeholder="请输入列" autocomplete="off"
                    class="layui-input" id="student_age">
            </div>
        </div>
        
        <div class="layui-form-item">
            <label class="layui-form-label">电影名字</label>
            <div class="layui-input-block">
                <input type="text" name="title" required lay-verify="required" placeholder="请输入电影名字" autocomplete="off"
                    class="layui-input" id="student_score">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">电影编号</label>
            <div class="layui-input-block">
                <input type="text" name="title" required lay-verify="required" placeholder="请输入电影编号" autocomplete="off"
                    class="layui-input" id="student_add">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
            <button type='button' id='addstudentBtn' class="layui-btn" lay-submit lay-filter="formDemo">添加</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        </form>
        </div>
        `)
    }
    handle() {
        $("script[type='module']").append(`
        <script>
        //Demo
        layui.use(['element','form'], function(){
            var $ = layui.jquery,
            upload = layui.upload
            ,layer = layui.layer;
            var form = layui.form,
            element = layui.element;
            element.render('#nav')
            form.render()
            });
           
        </script>
        `)
        $('#addstudentBtn').click(() => {
            $.ajax({
                type: 'post',
                url: '/seats/selectSeat',
                data: {
                    row: () => $("#student_name").val(),
                    col: () => $("#student_age").val(),
                    displayName: () => $("#student_score").val(),
                    theaterId: () => $("#student_add").val(),
                },
                dataType: 'json',
                success: (data) => {
                    if (data.code == 1) {
                        alert(data.msg);
                        window.location.hash = '#/main/seatsList'
                    } else {
                        alert(data.msg);
                    }
                }
            })
        })
    }
}